package indiwood.model.service;

import indiwood.model.NoticeListVO;
import indiwood.model.NoticeVO;
import indiwood.model.PagingBean;
import indiwood.model.dao.NoticeDAO;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

@Service
public class NoticeServiceImpl implements NoticeService {
	@Resource(name = "noticeDAOImpl")
	private NoticeDAO noticeDAO;
	@Override
	public void write(NoticeVO nvo) {
		noticeDAO.write(nvo);
	}
	@Override
	public NoticeVO showContentNoHit(int no) {
		return noticeDAO.showContent(no);
	}
	@Override
	public NoticeListVO noticeList(String pageNo) {
		if (pageNo == null || pageNo == "")
			pageNo = "1";
		List<NoticeVO> list = noticeDAO.noticeList(pageNo);
		int total = noticeDAO.totalContent();
		PagingBean paging = new PagingBean(total, Integer.parseInt(pageNo));
		NoticeListVO lvo = new NoticeListVO(list, paging);
		return lvo;
	}
	@Override
	public NoticeVO showContent(int no) {
		noticeDAO.updateCount(no);
		return noticeDAO.showContent(no);
	}
	@Override
	public void updateBoard(NoticeVO nvo) {
		noticeDAO.updateBoard(nvo);
	}
	@Override
	public void deleteBoard(String no) {
		noticeDAO.deleteBoard(no);
	}
}
